<template>
    <div>
        <h1 style="text-align:center">登陆</h1>
        <el-row>
            <el-col :span="8">.</el-col>
            <el-col :span="8">
                <el-form :model="ruleForm" ref="ruleForm" width="100px">
                    <el-form-item prop="name" label="用户名">
                        <el-input v-model="ruleForm.code"></el-input>
                    </el-form-item>
                    <el-form-item label="密码" prop="pass">
                        <el-input type="password" v-model="ruleForm.pwd" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="submitForm">登陆</el-button>
                    </el-form-item>
                </el-form>
            </el-col>
            <el-col :span="8"></el-col>
        </el-row>
        <router-view/>
    </div>
</template>

<script>
import {login} from "../service/review"
import { mapMutations } from 'vuex'
export default {
    data(){
        return{
            ruleForm:{},
            param:{}
        }
    },
    methods:{
        ...mapMutations('review',['setToken']),
        async submitForm(formName) {
            let response = await login(this.ruleForm.code,this.ruleForm.pwd);
            console.log("login:",response)
            if(response.status != 1){
                this.$notify({
                    title: '失败',
                    message: '用户名或密码错误',
                    offset: 400
                });
            }else{
                this.setToken(response.data)
                this.$cookies.set("token",response.data.token);
                this.$cookies.set("refreshToken",response.data.refreshToken);
                this.$router.push("/reviewIndex");
            }
            
        },
    }
}
</script>

<style>

</style>